import React from 'react';
import './app.css'

// 导入 组件props的校验规则 yarn add prop-types
import PropTypes from "prop-types"

function ListItem({ children, list }) {
  // 组件内部有其他元素时具有children属性
  console.log(children)
  return (
    <div>item</div>
  )
}
// 添加校验
ListItem.propTypes = {
  // 要求list为数组
  list: PropTypes.array
}

class App extends React.Component {
  state = {
    msg: "this is msg",
    list: [1, 2, 3]
  }

  render() {
    return (
      <div className="App" >
        <ListItem list={this.state.list}>
          text text
          <div>inner div</div>
          {<div>{this.state.msg}</div>}
          {() => console.log(123)}
        </ListItem>
      </div>
    )
  }
}

export default App;
